package com.gaber.collection;

import java.util.HashMap;

/**
 * @author gaber
 * @date 2023/7/12 17:15:55
 * @description TODO
 */
public class HashMapTest {
    public static void main(String[] args) {
        HashMap<Integer, String> sites = new HashMap<>();
        //添加键值对
        sites.put(1,"gaber");
        sites.put(2,"Runoob");
        sites.put(3, "Taobao");
        sites.put(4, "Zhihu");
        System.out.println(sites.get(1));

        sites.remove(3);
        System.out.println(sites);

//        sites.clear();
//        System.out.println(sites);

        int size = sites.size();
        System.out.println(size);

        // 输出key和value
        for (Integer i: sites.keySet()
             ) {
            System.out.println(i + " " + sites.get(i));
        }

        for (String value: sites.values()
             ) {
            System.out.print(value + " ");
        }

    }
}
